#include "widget.h"
#include "ui_widget.h"
#include <fstream>
#include <QDebug>
#include <string>
#include <QString>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
//    ui->comboBox->addItem("米饭");
//    ui->comboBox->addItem("面条");
//    ui->comboBox->addItem("馒头");

    //读文件进行Item的设置
    std::ifstream ifs("C:/Qt/for-learning-qt/InputWidgetExp3/Staplefood.txt");
    if(!ifs.is_open())
    {
        ifs.close();
    }
    else
    {
        std::string line;
        while(std::getline(ifs, line))
        {
            ui->comboBox->addItem(QString(line.c_str()));
        }
    }
    ifs.close();
    ui->spinBox->setRange(0,5);


    ui->comboBox_2->addItem("白菜");
    ui->comboBox_2->addItem("西红柿");
    ui->comboBox_2->addItem("油麦菜");
    ui->spinBox_2->setRange(0,3);

    ui->comboBox_3->addItem("鸡肉");
    ui->comboBox_3->addItem("猪肉");
    ui->comboBox_3->addItem("鸭肉");
    ui->spinBox_3->setRange(0,2);
}

Widget::~Widget()
{
    delete ui;
}

